package com.feemanage.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.common.annotation.Anonymous;
import com.common.core.domain.R;
import com.common.core.page.PageDomain;
import com.common.core.page.TableDataInfo;
import com.common.validate.edit;
import com.feemanage.domain.SysSnrule;
import com.feemanage.service.ISysSnruleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 编号规则 操作处理
 */
@Api(tags="编号规则")
@RestController
@RequestMapping("/feemanage/snrule")
public class SysSnruleController {

    @Autowired
    private ISysSnruleService baseService;

    /**
     * 查询编号规则列表
     * @param pageDomain
     * @param sysSnrule
     * @return
     */
    @ApiOperation("查询编号规则列表")
    @GetMapping("/list")
    public TableDataInfo list(PageDomain pageDomain, SysSnrule sysSnrule){
        IPage<SysSnrule> page = baseService.selectList(pageDomain,sysSnrule);
        return TableDataInfo.build(page.getRecords(),page.getTotal());
    }

    /**
     * 编辑规则
     * @param sysSnrule
     * @return
     */
    @ApiOperation("编辑编号规则")
    @PostMapping("/edit")
    public R<Void> editSnrule(@Validated(edit.class) @RequestBody SysSnrule sysSnrule){
        boolean result = baseService.editSnrule(sysSnrule);
        return result ? R.ok() : R.fail();
    }
}
